package com.ujiuye.servlet;

import com.ujiuye.entity.User;
import com.ujiuye.service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/login")
public class LoginServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //接受请求参数
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        //调用业务
        UserService us = new UserService();
        User user = us.login(username,password);
        //响应处理结果
        if(user!=null){
            System.out.println("登录成功");
        }else {
            System.out.println("登录失败");
        }

    }
}
